home *** CD-ROM | disk | FTP | other *** search
/ Holt Researcher: American History / Holt Researcher: American History.iso / pc / modules / dbtext.dxr / 00004_DB Text Var.ls < prev    next >
Encoding:
Text File  |  2000-01-18  |  8.6 KB  |  324 lines

  1. property pWindowName, pSpriteList, pMaxRect, pMinRect, pButtonList, pTracking, pPointingCursor, pMemberNum, pMember, pNArrowObj, pSArrowObj, pSliderObj, pFieldLeft, pFieldTop, pFieldRight, pFieldBottom, pLineHeight, pStartX, pStartTop, pStartBottom, pEndTop, pEndX, pEndBottom, pStartSel, pMiddleSel, pEndSel, pRolloverTextObj, pBorderRectList, pTextRectList
  2.  
  3. on new me
  4.   pButtonList = [:]
  5.   pTracking = 0
  6.   pPointingCursor = [member("point hand"), member("point hand mask")]
  7.   return me
  8. end
  9.  
  10. on init me
  11.   NArrowSp = getaProp(pSpriteList, #NArrow)
  12.   pNArrowObj = getaProp(pButtonList, NArrowSp)
  13.   SArrowSp = getaProp(pSpriteList, #SArrow)
  14.   pSArrowObj = getaProp(pButtonList, SArrowSp)
  15.   ThumbSp = getaProp(pSpriteList, #VThumb)
  16.   pSliderObj = getaProp(pButtonList, ThumbSp)
  17.   FieldRect = the rect of sprite getaProp(pSpriteList, #text)
  18.   pFieldLeft = getAt(FieldRect, 1)
  19.   pFieldTop = getAt(FieldRect, 2)
  20.   pFieldRight = getAt(FieldRect, 3)
  21.   pFieldBottom = getAt(FieldRect, 4)
  22.   pLineHeight = the textHeight of field pMemberNum
  23.   member("texthold f").text = EMPTY
  24.   SetPuppetState([7, 9], #c, 1)
  25. end
  26.  
  27. on HiliteText me, clickedSprite
  28.   pTracking = 1
  29.   StartChar = the mouseChar
  30.   repeat while the stillDown
  31.     SelectionScroll(me)
  32.     X = the mouseH
  33.     Y = the mouseV
  34.     if X <= pFieldLeft then
  35.       X = pFieldLeft + 1
  36.     end if
  37.     if X >= pFieldRight then
  38.       X = pFieldRight - 1
  39.     end if
  40.     if Y <= pFieldTop then
  41.       Y = pFieldTop + 1
  42.     end if
  43.     if Y >= pFieldBottom then
  44.       Y = pFieldBottom - 1
  45.     end if
  46.     EndChar = locToCharPos(member(pMemberNum), point(X - pFieldLeft, Y - pFieldTop))
  47.     SetSelections(me, StartChar, EndChar)
  48.     SetVisSelections(me)
  49.   end repeat
  50.   CalcFinalSelection(me, StartChar, EndChar)
  51.   pTracking = 0
  52. end
  53.  
  54. on SetSelections me, StartChar, EndChar
  55.   TempStart = min(StartChar, EndChar)
  56.   TempEnd = max(StartChar, EndChar)
  57.   StartChar = TempStart
  58.   EndChar = TempEnd
  59.   StartLoc = charPosToLoc(member(pMemberNum), StartChar)
  60.   pStartX = getAt(StartLoc, 1) + pFieldLeft
  61.   pStartTop = getAt(StartLoc, 2) + pFieldTop - member(pMemberNum).scrollTop + GetHiliteAdjustment(me)
  62.   pStartBottom = pStartTop + pLineHeight
  63.   EndLoc = charPosToLoc(member(pMemberNum), EndChar)
  64.   pEndTop = getAt(EndLoc, 2) + pFieldTop - member(pMemberNum).scrollTop + GetHiliteAdjustment(me)
  65.   pEndX = getAt(EndLoc, 1) + pFieldLeft
  66.   pEndBottom = pEndTop + pLineHeight
  67.   if pStartTop = pEndTop then
  68.     pStartSel = rect(pStartX, pStartTop, pEndX, pStartBottom)
  69.     pEndSel = #NotUsed
  70.   else
  71.     if pStartTop < pEndTop then
  72.       pStartSel = rect(pStartX, pStartTop, pFieldRight, pStartBottom)
  73.       pEndSel = rect(pFieldLeft, pEndTop, pEndX, pEndBottom)
  74.     end if
  75.   end if
  76.   SetMiddleSelection(me)
  77. end
  78.  
  79. on SetMiddleSelection me
  80.   if ilk(pEndSel) = #rect then
  81.     pMiddleSel = rect(pFieldLeft, getAt(pStartSel, 4), pFieldRight, getAt(pEndSel, 2))
  82.   else
  83.     pMiddleSel = #NotUsed
  84.   end if
  85. end
  86.  
  87. on SetVisSelections me
  88.   set the rect of sprite 7 to getVisSelection(me, pStartSel)
  89.   set the rect of sprite 8 to getVisSelection(me, pEndSel)
  90.   set the rect of sprite 9 to getVisSelection(me, pMiddleSel)
  91.   updateStage()
  92. end
  93.  
  94. on getVisSelection me, selRect
  95.   if ilk(selRect) = #rect then
  96.     R = rect(-1, -1, -1, -1)
  97.     if not ((selRect.top > pFieldBottom) or (selRect.bottom < pFieldTop)) then
  98.       R.left = max(selRect.left, pFieldLeft)
  99.       R.top = max(selRect.top, pFieldTop)
  100.       R.right = min(selRect.right, pFieldRight)
  101.       R.bottom = min(selRect.bottom, pFieldBottom)
  102.     end if
  103.   else
  104.     R = rect(-1, -1, -1, -1)
  105.   end if
  106.   return R
  107. end
  108.  
  109. on SelectionScroll me
  110.   if the mouseV < pFieldTop then
  111.     if not minReached(pSliderObj) then
  112.       simulateClickOn(pNArrowObj)
  113.     end if
  114.   else
  115.     if the mouseV > pFieldBottom then
  116.       if not maxReached(pSliderObj) then
  117.         simulateClickOn(pSArrowObj)
  118.       end if
  119.     end if
  120.   end if
  121. end
  122.  
  123. on scroll me, NewSetting
  124.   diff = NewSetting - (member(pMemberNum).scrollTop / pLineHeight)
  125.   increment = diff * pLineHeight
  126.   pStartSel = ScrollMoveSelection(me, pStartSel, increment)
  127.   pEndSel = ScrollMoveSelection(me, pEndSel, increment)
  128.   SetMiddleSelection(me)
  129.   if not pTracking then
  130.     SetVisSelections(me)
  131.   end if
  132.   return me
  133. end
  134.  
  135. on ScrollMoveSelection me, SelectionRect, increment
  136.   if ilk(SelectionRect) = #rect then
  137.     SelectionRect.top = SelectionRect.top - increment
  138.     SelectionRect.bottom = SelectionRect.bottom - increment
  139.   end if
  140.   return SelectionRect
  141. end
  142.  
  143. on CalcFinalSelection me, StartChar, EndChar
  144.   TempStart = min(StartChar, EndChar)
  145.   TempEnd = max(StartChar, EndChar)
  146.   StartChar = TempStart
  147.   EndChar = TempEnd
  148.   member("texthold f").text = char StartChar to EndChar - 1 of the text of field pMemberNum
  149.   if not (member("texthold f").text = EMPTY) then
  150.     enable(getaProp(pButtonList, getaProp(pSpriteList, #CopyButton)))
  151.   else
  152.     disable(getaProp(pButtonList, getaProp(pSpriteList, #CopyButton)))
  153.   end if
  154. end
  155.  
  156. on GetHiliteAdjustment me
  157.   if the machineType = 256 then
  158.     return -pLineHeight
  159.   else
  160.     return -pLineHeight
  161.   end if
  162. end
  163.  
  164. on ResetSelections me
  165.   pStartSel = #NotUsed
  166.   pMiddleSel = #NotUsed
  167.   pEndSel = #NotUsed
  168.   set the rect of sprite 7 to rect(-333, -333, -333, -333)
  169.   set the rect of sprite 8 to rect(-333, -333, -333, -333)
  170.   set the rect of sprite 9 to rect(-333, -333, -333, -333)
  171.   updateStage()
  172. end
  173.  
  174. on InitRollOverText me
  175.   rolloverList = []
  176.   setAt(rolloverList, getaProp(pSpriteList, #closeBox), 16)
  177.   setAt(rolloverList, getaProp(pSpriteList, #CopyButton), 13)
  178.   setAt(rolloverList, getaProp(pSpriteList, #PrintButton), 11)
  179.   setAt(rolloverList, getaProp(pSpriteList, #SaveButton), 10)
  180.   setAt(rolloverList, getaProp(pSpriteList, #MaxMinBox), 18)
  181.   pRolloverTextObj = new(script("rollover text"), rolloverList)
  182. end
  183.  
  184. on print me
  185.   global gEnvironObj
  186.   if not isMemoryAvailable("print the document", 1200, 500) then
  187.     exit
  188.   end if
  189.   TitleMember = the number of member "print title f"
  190.   xMember = GetMemberNum(me)
  191.   unLoad()
  192.   doc = new(xtra("PrintOMatic"))
  193.   if not objectp(doc) then
  194.     alert("A problem was encountered while initializing the printer.")
  195.     exit
  196.   end if
  197.   pageW = getPageWidth(doc)
  198.   pageH = getPageHeight(doc)
  199.   set the textSize of member TitleMember to 14
  200.   member(TitleMember).rect = rect(0, 0, pageW, 0)
  201.   TitleH = member(TitleMember).height
  202.   pgNumSym = numToChar(166)
  203.   setPageNumSymbol(doc, pgNumSym)
  204.   setTextJust(doc, "left")
  205.   newPage(doc)
  206.   setTextJust(doc, "centered")
  207.   newFrame(doc, rect(0, 0, pageW, TitleH + 18), 0)
  208.   append(doc, member(TitleMember), 0)
  209.   setTextJust(doc, "left")
  210.   newFrame(doc, rect(0, 0, pageW, pageH - 18), 0)
  211.   append(doc, " ", 1)
  212.   count = (TitleH / 14) + 1
  213.   repeat with i = 1 to count
  214.     append(doc, RETURN, 1)
  215.   end repeat
  216.   member("print media", 1).media = member(xMember, "DBText.CST").media
  217.   append(doc, member("print media", 1), 1)
  218.   if the machineType = 256 then
  219.     setTextFont(doc, "Arial")
  220.   else
  221.     setTextFont(doc, "Helvetica")
  222.   end if
  223.   setTextSize(doc, 12)
  224.   setTextStyle(doc, "normal")
  225.   drawText(doc, member("copyright HRW").text, point(0, pageH))
  226.   setDocumentName(doc, "American History")
  227.   if doJobSetup(doc) then
  228.     print(doc)
  229.   end if
  230.   doc = 0
  231. end
  232.  
  233. on save me
  234.   xMember = GetMemberNum(me)
  235.   fileName = MakePlatformFileName(the text of field "title f" of castLib 1) & GetTextExtension()
  236.   pathAndName = GetSavePathandName(fileName)
  237.   if pathAndName <> EMPTY then
  238.     saveTextFile(pathAndName, member(xMember).text)
  239.   end if
  240.   return me
  241. end
  242.  
  243. on doRolloverText me
  244.   doRolloverText(pRolloverTextObj)
  245. end
  246.  
  247. on SetButtonList me, xList
  248.   pButtonList = xList
  249. end
  250.  
  251. on GetButtonList me
  252.   return pButtonList
  253. end
  254.  
  255. on ResizeScroll me, theThumbLoc, minPixel, maxPixel, initialSetting, numSettings, minSetting, maxSetting
  256.   resize(pSliderObj, theThumbLoc, minPixel, maxPixel, initialSetting, numSettings, minSetting, maxSetting)
  257. end
  258.  
  259. on SetBorderRect me, xList
  260.   pBorderRectList = xList
  261. end
  262.  
  263. on GetBorderRect me, size
  264.   return getAt(pBorderRectList, size)
  265. end
  266.  
  267. on SetTextRect me, xList
  268.   pTextRectList = xList
  269. end
  270.  
  271. on GetTextRect me, size
  272.   return getAt(pTextRectList, size)
  273. end
  274.  
  275. on GetPointingCursor me
  276.   return pPointingCursor
  277. end
  278.  
  279. on SetMemberNum me, Var
  280.   pMemberNum = Var
  281. end
  282.  
  283. on GetMemberNum me
  284.   return pMemberNum
  285. end
  286.  
  287. on SetMember me, xName
  288.   pMember = xName
  289. end
  290.  
  291. on GetMember me
  292.   return pMember
  293. end
  294.  
  295. on SetSpriteList me, list
  296.   pSpriteList = list
  297. end
  298.  
  299. on GetSpriteList me
  300.   return pSpriteList
  301. end
  302.  
  303. on condemn me
  304.   pButtonList = CondemnList(me, pButtonList)
  305.   condemn(pNArrowObj)
  306.   pNArrowObj = 0
  307.   condemn(pSArrowObj)
  308.   pSArrowObj = 0
  309.   condemn(pSliderObj)
  310.   pSliderObj = 0
  311.   pRolloverTextObj = 0
  312.   return me
  313. end
  314.  
  315. on CondemnList me, xList
  316.   MaxCount = count(xList)
  317.   repeat with rc = 1 to MaxCount
  318.     xObj = getAt(xList, rc)
  319.     condemn(xObj)
  320.     setAt(xList, rc, 0)
  321.   end repeat
  322.   return 0
  323. end
  324.